<template>
  <div id="app">
    <nav></nav>
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive" />
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive" />

    <div v-show="isshow" class="tabbar-b">
      <van-tabbar fixed v-model="active">
        <van-tabbar-item name="/home" icon="home-o"  to="/home"
          >首页</van-tabbar-item
        >
        <van-tabbar-item name="/clock" icon="notes-o"  to="/clock"
          >打卡</van-tabbar-item
        >
        <van-tabbar-item name="/dynamic"  :to="`${islogin == true || islogin == 'true'?'/dynamic':'/login'}`">
          <van-icon name="add-o" size="40" color="#000" />
        </van-tabbar-item>
        <van-tabbar-item name="/record"  to="/record" icon="todo-list-o"
          >记录</van-tabbar-item
        >
        <van-tabbar-item name="/mine"  to="/mine" icon="contact"
          >我的</van-tabbar-item
        >
      </van-tabbar>
    </div>
  </div>
</template>
<script>
import { mapState } from 'vuex';
import AppBar from "./components/AppBar.vue";
export default {
  computed: {
    ...mapState(["islogin"])
  },
  components: { AppBar },

  beforeUpdate () {
    // console.log(this.$route.fullPath);
    this.lupath = this.$route.fullPath;

  }, 
  data() {
    return {
      isshow: true,
      active:'/home',
      lupath:null
    }
  },
  watch: {
    lupath(newValue, oldValue) {
      this.active = newValue
     if (newValue=='/home'||newValue=='/clock'||newValue=='/record'||newValue=='/mine') {
       this.isshow = true
     }else{
       this.isshow = false
     }

    }
  },
};
</script>
<style lang="scss">
// #app {
//   font-family: Avenir, Helvetica, Arial, sans-serif;
//   -webkit-font-smoothing: antialiased;
//   -moz-osx-font-smoothing: grayscale;
//   text-align: center;
//   color: #2c3e50;
// }

// nav {
//   padding: 30px;

//   a {
//     font-weight: bold;
//     color: #2c3e50;

//     &.router-link-exact-active {
//       color: #42b983;
//     }
//   }
// }
.tabbar-b{
  height: 50px;
}
</style>
